import requests
import json
from appAccounts.config import url_CustomerWS
from appAccounts.utils.log_utils import logger

def do_check_customer(cust_id: str, c_token: str):
    try:
        logger.info(f"Try to connect to {url_CustomerWS}")

        payload = json.dumps({
            "id": f"{cust_id}"
        })

        cust_headers = {
            'Content-Type': 'application/json',
            'Authorization': f'Bearer {c_token}'
        }

        logger.info(cust_headers)
        logger.info(payload)

        response = requests.request("GET", url_CustomerWS, headers=cust_headers, data=payload, timeout=10)

        logger.info(response.text)
        response.raise_for_status()  # Raise an exception for HTTP errors
        return True

    except requests.exceptions.RequestException as e:
        logger.error(f"An error occurred: {e}")
